#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include <QVector>
#include "tchar.h"
#include <time.h>
#include <QVector>
#include <QThread>
#include "menu2.h"
#include "mypushbutton.h"
#include <QTimer>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //配置主场景
    //设置固定大小
    this->setFixedSize(1200,900);
    //设置图标
    setWindowIcon(QIcon(":/images/monster_up.png"));
    //设置标题
    setWindowTitle("喵斯快跑");

    //开始按钮
    MyPushButton *startBtn = new MyPushButton(":/images/MenuSceneStartButton.png");
    startBtn->setParent(this);
    startBtn->move(this->width()*0.5-startBtn->width()*0.5,this->height()*0.7);

    //配置第二个场景
    menu2 = new Menu2;
    connect(startBtn,&MyPushButton::clicked,[=](){
       //做谈起特效
        startBtn->zoom1();
        startBtn->zoom2();
        //延时进入到第二个场景中
        QTimer::singleShot(500,this,[=](){
            //设置第二个场景的位置
            menu2->setGeometry(this->geometry());
            //自身隐藏
            this->hide();
            //显示第二个场景
            menu2->show();
        });
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    //画游戏的背景
    QPixmap pix;
    pix.load(":/images/1bk.jpg");
    painter.drawPixmap(0,0,1200,900,pix);

    pix.load(":/images/run0.png");
}

